package razor.blade;

import tee.binding.*;
import javafx.beans.property.*;
import javafx.beans.value.*;

public class Tee<Kind> extends SimpleObjectProperty<Kind> {
    private It<Kind> o;
    public Tee(It<Kind> it) {
	super();
	o = new It<Kind>().bind(it).afterChange(new Task() {
	    @Override public void doTask() {
		if(o!=null)
		set(o.value());
	    }
	});
	addListener(new ChangeListener<Kind>() {
	    public void changed(ObservableValue<? extends Kind> observable, Kind oldValue, Kind newValue) {
		if(o!=null)
		o.value(get());
	    }
	});
	this.set(it.value());
    }
}
